@extends('default.mobile.layouts.indexPublic')
@section('title'){{$job_search.Site::get('area_name').'找工作|最新招聘信息|'.Site::get('webname')}} @endsection

{{--首页css--}}
@section('headcss')
    @parent
    <link rel="stylesheet" href="{{asset('/default/css/mobile/index/common.css')}}">
    <link rel="stylesheet" href="{{asset('/default/css/mobile/jquery/select.css')}}">
    @endsection
    {{--头部标签--}}
    @section('tag',$jobTitle)

    {{--主体内容--}}
    @section('content')
            <!-- B搜索框 -->
    <div class="list_search_main">
        <div class="list_search_bar">
            <form action="{{url('mobile/job')}}" method="post" name="jobForm" id="jobForm">
                {{csrf_field()}}
                <input name="nearby" type="hidden" id="nearby" value="{{$nearby}}">
                <input name="position_denied" type="hidden" id="position_denied" value="{{$position_denied or ''}}">
                <input name="_lng" type="hidden" id="_lng" value="{{$_lng or ''}}">
                <input name="_lat" type="hidden" id="_lat" value="{{$_lat or ''}}">
                <span><input name="keyword" type="text" value="{{ old('keyword') }}" placeholder="搜索职位/公司"
                             autocomplete="off"></span>
                <span><input name="submit" class="sub" value="" type="submit"></span>
                <span><a class="clear">清除</a></span>
            </form>
        </div>
    </div>
    <!-- E搜索框 -->
    <!-- B 选择 -->
    <div class="select_outer" id="select_outer">
        <ul>
            <li id="area_select"><input type="hidden" name="jobarea1" value="{{$input['jobarea1'] or ''}}"
                                        id="jobarea1"/><a><span class="select_text">地区</span><em></em></a></li>
            <li id="salary_select"><input type="hidden" name="salary" value="{{$input['salary'] or ''}}"
                                          id="salary"/><a><span class="select_text">薪资</span><em></em></a></li>
            <li id="work_year_select"><input type="hidden" name="work_year" value="{{$input['work_year'] or ''}}"
                                             id="work_year"/><a><span class="select_text">经验</span><em></em></a></li>
            <li id="education_select"><input type="hidden" name="education" value="{{$input['education'] or ''}}"
                                             id="education"/><a><span class="select_text">学历</span><em></em></a></li>
        </ul>
    </div>
    <!-- E 选择 -->

    <!-- B 职位列表-->
    @if(count($company_job) > 0)
        <div class="list_box">
            @foreach($company_job as $v)
                <div class="list_info">
                    <a href="{{url('mobile/jobinfo_'.idEncryption($v->id).'.html')}}">
                        <dl>
                            <dt>
                        <span class="title">
                            <span class="job_title">{{ str_limit($v->job_title,18) }}</span>
                            @if(!empty($v->part_status) && $v->part_status == '2')
                                <em class="one"></em>
                            @elseif(!empty($v->part_status) && $v->part_status == '3')
                                <em class="two"></em>
                            @elseif(!empty($v->part_status) && $v->part_status == '4')
                                <em class="three"></em>
                            @endif
                            @if($v->urgent ==1 ) <i></i> @endif
                        </span>
                                @if($v->urgent ==1 ) <i></i> @endif
                                <time>{{ substr($v->updatetime,0,10) }}</time>
                            </dt>
                            <dd>
                                <span class="money">{{ $v->salary_above }}</span>
                                @if( $v->education != '' )<b>|</b><span class="edu">{{ $v->education }}</span>@endif
                                @if( $v->work_year != '' )<b>|</b><span class="edu">{{ $v->work_year }}</span>@endif
                                @if(!empty($nearby))<span class="juli"
                                                          id="juli"><em>{{ str_limit($v->juli,16) }}</em><i></i></span>@endif
                            </dd>
                            <dd class="line">
                                <span class="company">{{ str_limit($v->company_name,26) }}</span>
                                <span class="address">{{ str_limit($v->location,16) }}</span>
                            </dd>
                        </dl>
                    </a>
                </div>
            @endforeach
        </div>
    @else
        <div class="list_empty">
            <span class="norecord"></span>
            <span class="sorry">抱歉，没有找到符合您条件记录！</span>
        </div>
        @endif
                <!-- E 职位列表-->
        <!-- B分页 -->
        <div class="page">
            @if($company_job->currentPage() <= 1 )
                <a class="btn_gary previous">上一页</a>
            @else
                <a href="{{$company_job->previousPageUrl()}}" class="previous">上一页</a>
            @endif
            <span><em>{{ $company_job->total()== 0 ? 1 : $company_job->currentPage()}}</em>/{{ $company_job->lastPage() == 0 ? 1 : $company_job->lastPage() }}</span>
            @if($company_job->currentPage() == $company_job->lastPage() || $company_job->lastPage() == 0 )
                <a class="btn_gary next">下一页</a>
            @else
                <a href="{{$company_job->nextPageUrl()}}" class="next">下一页</a>
            @endif
        </div>
        <!-- E分页 -->
@endsection
@section('footerjs')
    @parent
    <script type="text/javascript" src="{{asset('/default/js/mobile/jquery/jquery.select.js')}}"></script>
    <script type="text/javascript" src="{{asset('/default/js/mobile/jquery/jquery.select_single.js')}}"></script>
    <script type="text/javascript" src="{{Resources::jsOption('resume')}}"></script>
    <script type="text/javascript" src="{{Resources::jsProvinceArea()}}"></script>

    @if(!empty($nearby))
        <script>
            var position_denied = '{{$position_denied}}';
        </script>
        <script type="text/javascript" src="{{asset('/default/js/mobile/index/nearby.js')}}"></script>
        <script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak={{Site::get('mapKey')}}"></script>
    @endif
    <script>
        var _token = '{{csrf_token()}}';
        var education_url = '{!!$optionsurl['education']!!}';
        var work_year_url = '{!!$optionsurl['work_year']!!}';
        var jobarea_url = '{!!$optionsurl['jobarea']!!}';
        var salary_url = '{!!$optionsurl['salary']!!}';
        //关键词
        var keyword_url = '{!! $optionsurl['keyword'] !!}';

        $(function(){
            var select_outer = $("#select_outer");
            //检查变量是不是存在
            var town = (typeof(option_town) != 'undefined') ? option_town.unshift({'value': '', 'text': '不限'}) : 0;
            var city = (typeof(option_city) != 'undefined') ? option_city.unshift({'value': '', 'text': '不限'}) : 0;
            select_outer.find("#area_select").select_single({
                select_title: '工作地区',
                hidden: '#jobarea1',
                opt_city: (city > 0) ? option_city : [],
                opt_town: (town > 0) ? option_town : [],
                opt_province: option_province,
                callback: function(val){
                    person_jump(jobarea_url, 'jobarea1', val);
                }
            });
            //薪资待遇
            var option_salary = [
                {'value': '', 'text': '不限'},
                {'value': '1', 'text': '2000以下'},
                {'value': '2', 'text': '2000-4000'},
                {'value': '3', 'text': '4000-6000'},
                {'value': '4', 'text': '6000-8000'},
                {'value': '5', 'text': '8000-1万'},
                {'value': '6', 'text': '1万-1.5万'},
                {'value': '7', 'text': '1.5万-2万'},
                {'value': '8', 'text': '2万-3万'},
                {'value': '9', 'text': '3万-4万'},
                {'value': '10', 'text': '4万-5万'},
                {'value': '11', 'text': '5万以上'}
            ];
            select_outer.find("#salary_select").select({
                select_title: '薪资待遇',
                hidden: '#salary',
                opt_data: option_salary,
                callback: function(val){
                    person_jump(salary_url, 'salary', val);
                }
            });
            //工作经验
            option_work_year.unshift({'value': '', 'text': '不限'});
            select_outer.find("#work_year_select").select({
                select_title: '工作经验',
                hidden: '#work_year',
                opt_data: option_work_year,
                callback: function(val){
                    person_jump(work_year_url, 'work_year', val);
                }
            });
            //学历
            option_education.unshift({'value': '', 'text': '不限'});
            select_outer.find("#education_select").select({
                select_title: '学历',
                hidden: '#education',
                opt_data: option_education,
                callback: function(val){
                    person_jump(education_url, 'education', val);
                }
            });
            //清除
            $('.list_search_main').find('.clear').click(function(){
                location.href = keyword_url;
            });
            //获取附近工作
            @if(!empty($nearby))
                getLocation();
            @endif
        });
        //跳转地址
        function person_jump(linkurl, define_link, val){
            var exl = "?";
            if(linkurl.indexOf("?") > 0){
                exl = '&';
            }
            location.href = linkurl + exl + define_link + '=' + val;
        }
    </script>
@endsection